package com.haoshuang.zhouzhoubang.ui.adapter


import com.chad.library.adapter4.BaseQuickAdapter
import com.haoshuang.zhouzhoubang.R
import com.haoshuang.zhouzhoubang.databinding.ItemZbBinding
import com.mufeng.libs.base.BaseBindingHolder
import com.mufeng.libs.base.BaseBindingQuickAdapter
import java.util.regex.Matcher
import java.util.regex.Pattern


/**
 * 订单模块中的订单列表适配器
 * */
class ZbAdapter(data: MutableList<String>) :
    BaseBindingQuickAdapter<String, ItemZbBinding>(data) {
    fun replaceBlank(src: String?): String {
        var dest = ""
        if (src != null) {
            val pattern: Pattern = Pattern.compile("\t|\r||\\s*")
            val matcher: Matcher = pattern.matcher(src)
            dest = matcher.replaceAll("")
        }
        return dest
    }

    override fun onBindViewHolder(holder: BaseBindingHolder, position: Int, item: String?) {
        val binding = ItemZbBinding.bind(holder.itemView)
        binding.apply {
            tvDesc.text = replaceBlank(item)
        }
    }
}